import org.apache.poi.ss.usermodel.Cell
import org.apache.poi.ss.usermodel.Workbook
import org.apache.poi.ss.usermodel.WorkbookFactory
import org.apache.poi.xssf.usermodel.XSSFCell


void m1() throws Exception {
    // Workbook wb = WorkbookFactory.create(new File("e:/tmp/案例结点_V2.xlsx"));
    Workbook wb = WorkbookFactory.create(new File("e:/tmp/结点测试案例.xlsx"));
    wb.getSheetAt(0).forEach{row ->
        if (row.getRowNum() == 0) return;
        Utils.Http http = Utils.http().post("http://19.19.22.119:8086/calculate")
        // .param("model_uuid", "2019031252273825") // 百融
                .param("model_uuid", "2019040153902759") // 聚信力
                .param("modelType", "GM")
                .param("version", "V1")
                .param("seq_id", "123");
        row.forEach { cell ->
            if (cell.getColumnIndex() == 0) return;
            String v = ((XSSFCell) cell).getRawValue();
            if (Utils.isEmpty(v)) return;
            Cell c = wb.getSheetAt(0).getRow(0).getCell(cell.getColumnIndex());
            if (c == null) return;
            if (Utils.isNotEmpty(c.getStringCellValue())) http.param(c.getStringCellValue(), v);
        };
        JSONObject rJo = JSON.parseObject(http.execute());
        JSONObject nJo = new JSONObject();
        nJo.put("credit_score", rJo.getJSONObject("data").getString("credit_score"));
        System.out.println(nJo);
        row.createCell(row.getLastCellNum() + 1).setCellValue(nJo.toJSONString());
    };
    wb.write(new FileOutputStream(new File("e:/tmp/result.xlsx")));
    wb.close();
}